<link rel="stylesheet" href="/static/markdown/css/editormd.preview.css"/>
<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <input type="hidden" id="ids" name="ids" value="{$model.ids ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <input type="hidden" id="flowcode" name="flowcode" value="{$model.ids_code ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <input type="hidden" id="table" name="table" value="{$model.ids_table ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <input type="hidden" id="task_id" name="task_id" value="{$model.task_id ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <div id="dy_html">
        <div class="layui-row">
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
                <div class="layui-form-item">
                    <label class="layui-form-label">申请人</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$model.username ?? ''}" lay-verify="required"
                               placeholder="请输入申请人" autocomplete="off"
                               class="layui-input" readonly>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
                <div class="layui-form-item">
                    <label class="layui-form-label">申请部门</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$model.group_name ?? ''}"
                               lay-verify="required" placeholder="请输入申请部门" autocomplete="off"
                               class="layui-input" readonly>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
                <div class="layui-form-item">
                    <label class="layui-form-label">申请日期</label>
                    <div class="layui-input-block">
                        <input type="text" name="now_time" lay-verify="required"
                               value="{$model.create_time ?? ''}"
                               placeholder="请输入申请日期"
                               autocomplete="off"
                               class="layui-input" readonly>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
                <div class="layui-form-item">
                    <label class="layui-form-label">类别</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$model.typeName.name ?? ''}"
                               lay-verify="required" placeholder="请输入申请部门" autocomplete="off"
                               class="layui-input" readonly>

                    </div>
                </div>
            </div>
            {if $model.typeName.name eq '用章'}
            {empty name="$model.zhang.yz_content"}
            <div class="layui-form-item ">
                <label class="layui-form-label">用章信息</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" disabled>{$model.content ?? ''}</textarea>
                </div>
            </div>
            {else /}
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">用章类别</label>
                    <div class="layui-input-block">
                        <input type="text" value="  {$model.zhang.name ?? ''}" required placeholder="用章类别"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md12">
                <div class="layui-form-item ">
                    <label class="layui-form-label">用章事由</label>
                    <div class="layui-input-block">
                        <textarea class="layui-textarea" disabled>{$model.zhang.yz_content ?? ''}</textarea>
                    </div>
                </div>
            </div>
            {/empty}
            {elseif $model.typeName.name eq '借款'}
            {empty name="$model.money.jk_money"}
            <div class="layui-form-item ">
                <label class="layui-form-label">借款信息</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" disabled>{$model.content ?? ''}</textarea>
                </div>
            </div>
            {else /}
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">借款金额</label>
                    <div class="layui-input-block">
                        <input type="text" value="  {$model.money.jk_money ?? ''}元" required placeholder="借款金额"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">金额(大写)</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$model.money.dx ?? ''}" required placeholder="借款金额(大写)"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">借款方式</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$model.money.jk_fs ?? ''}" required placeholder="借款方式"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">收款名称</label>
                    <div class="layui-input-block">
                        <input type="text" value="  {$model.money.sk_name ?? ''}" required placeholder="收款名称"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">收款账号</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$model.money.sk_zh ?? ''}" required placeholder="收款账号"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
                <div class="layui-form-item ">
                    <label class="layui-form-label">开户行</label>
                    <div class="layui-input-block">
                        <input type="text" value="{$model.money.sk_khh ?? ''}" required placeholder="开户行"
                               autocomplete="off"
                               class="layui-input" disabled>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
                <div class="layui-form-item ">
                    <label class="layui-form-label">借款用途</label>
                    <div class="layui-input-block">
                        <textarea class="layui-textarea" disabled>{$model.money.sk_content ?? ''}</textarea>
                    </div>
                </div>
            </div>
            {/empty}
            {elseif $model.typeName.name eq '用车'}
            {empty name="$model.che"}
            <div class="layui-form-item ">
                <label class="layui-form-label">车辆信息</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" disabled>{$model.content ?? ''}</textarea>
                </div>
            </div>
            {else /}
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
                <div class="layui-form-item ">
                    <label class="layui-form-label">车辆信息</label>
                    <div class="layui-input-block">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th style="text-align: center;">起始地点</th>
                                <th style="text-align: center;">计划线路</th>
                                <th style="text-align: center;">开始时间</th>
                                <th style="text-align: center;">结束时间</th>
                                <th style="text-align: center;">用车天数</th>
                                <th style="text-align: center;">司机姓名</th>
                                <th style="text-align: center;">司机号码</th>
                                <th style="text-align: center;">用车人</th>

                            </tr>
                            </thead>
                            <tbody>
                            {foreach $model.che as $key=>$value}
                            <tr>
                                <td>
                                    {$value.start_address ?? ''}
                                </td>
                                <td style="text-align: center;">
                                    {$value.plan_lx ?? ''}
                                </td>
                                <td style="text-align: center;">{$value.start_time ?? ''}</td>
                                <td>
                                    {$value.end_time ?? ''}
                                </td>
                                <td style="text-align: center;">
                                    {$value.day ?? ''}
                                </td>
                                <td style="text-align: center;">{$value.sj_name ?? ''}</td>
                                <td>
                                    {$value.sj_phone ?? ''}
                                </td>

                                <td style="text-align: center;">{$value.ycr ?? ''}</td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            {/empty}
            {elseif $model.typeName.name eq '采购'}
            {empty name="$model.caigou"}
            <div class="layui-form-item ">
                <label class="layui-form-label">采购信息</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" disabled>{$model.content ?? ''}</textarea>
                </div>
            </div>
            {else /}
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
                <div class="layui-form-item ">
                    <label class="layui-form-label">采购信息</label>
                    <div class="layui-input-block">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th style="text-align: center;">品名规格</th>
                                <th style="text-align: center;">数量</th>
                                <th style="text-align: center;">备注</th>

                            </tr>
                            </thead>
                            <tbody id="index-table">
                            {foreach $model.caigou as $key=>$value}
                            <tr>
                                <td>
                                    {$value.cg_guige ?? ''}
                                </td>
                                <td style="text-align: center;">
                                    {$value.cg_num ?? ''}
                                </td>
                                <td style="text-align: center;">{$value.content ?? ''}</td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
                <div class="layui-form-item ">
                    <label class="layui-form-label">采购信息</label>
                    <div class="layui-input-block">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th style="text-align: center;">品名规格</th>
                                <th style="text-align: center;">数量</th>
                                <th style="text-align: center;">备注</th>

                            </tr>
                            </thead>
                            <tbody id="index-table">
                            {foreach $model.caigou as $key=>$value}
                            <tr>
                                <td>
                                    {$value.cg_guige ?? ''}
                                </td>
                                <td style="text-align: center;">
                                    {$value.cg_num ?? ''}
                                </td>
                                <td style="text-align: center;">{$value.content ?? ''}</td>
                            </tr>
                            {/foreach}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            {/empty}
            {/if}
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
                <div class="layui-form-item">
                    <label class="layui-form-label">审批记录</label>
                    <div class="layui-input-block">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <td>审批人</td>
                                <td>审批步骤</td>
                                <td>审批意见</td>
                                <td>审批时间</td>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="history" id="vo" }
                            <tr>
                                <td>{$vo.nickname}</td>
                                <td>{$vo.stepname}</td>
                                <td>{$vo.comment}</td>
                                <td>{$vo.completedtime}</td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {if $model.typeName.name eq '借款'}
    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" lay-submit lay-filter="dy" class="layui-btn">打印</button>
            </div>
        </div>
    </div>
    {/if}
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-user-back-submit" id="LAY-user-back-submit" value="确认">
    </div>
</div>
<script src="/static/markdown/js/jquery.min.js"></script>
<script src="/static/markdown/lib/marked.min.js"></script>
<script src="/static/markdown/lib/prettify.min.js"></script>
<script src="/static/markdown/lib/raphael.min.js"></script>
<script src="/static/markdown/lib/underscore.min.js"></script>
<script src="/static/markdown/lib/sequence-diagram.min.js"></script>
<script src="/static/markdown/lib/flowchart.min.js"></script>
<script src="/static/markdown/lib/jquery.flowchart.min.js"></script>
<script src="/assets/libs/editormd/editormd.min.js"></script>
<script src="/static/admin/layui/layui.js"></script>
<script src="/static/admin/js/jquery.PrintArea.js"></script>
<script>
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
    }).use(['index', 'upload', 'laydate', 'form'], function () {
        var $ = layui.$, form = layui.form, upload = layui.upload, laydate = layui.laydate;
        //常规用法
        laydate.render({
            elem: '#test1'
            , trigger: 'click'//呼出事件改成click
            , value: "{$time}"
            , type: 'datetime'

        });
        $.ajax({
            type: "post",
            url: "{:url('applies/type')}",
            data: {"id": $('#type_id option:selected').val()},
            dataType: "json",
            success: function (res) {
                $("#type_name").empty();
                $('#type_name').append(new Option("", 0));// 下拉菜单里添加元素
                $.each($.parseJSON(res), function (index, item) {
                    $('#type_name').append(new Option(item));// 下拉菜单里添加元素
                });
                if ($('#name_value').val() != "") {
                    $("select[name='type_name']").val($('#name_value').val());
                    // $("#type_name").find("option[value='财务章']").attr("selected", "selected");
                }
                layui.form.render("select");
            }
        });
        form.on('select(type)', function (data) {
            $.ajax({
                type: "post",
                url: "{:url('applies/type')}",
                data: {"id": data.value},
                dataType: "json",
                success: function (res) {
                    $("#type_name").empty();
                    $('#type_name').append(new Option("", 0));// 下拉菜单里添加元素
                    $.each($.parseJSON(res), function (index, item) {
                        $('#type_name').append(new Option(item));// 下拉菜单里添加元素
                    });

                    layui.form.render("select");
                }
            });
            $('#qita').val('');
            $('#remarks').val('');
        });
        form.on('select(type_name)', function (data) {
            if (data.value == "其他") {
                layer.prompt(function (value, index, elem) {
                    $('#qita').val(value);
                    layer.close(index);
                });
            } else {
                $('#qita').val('');
                $('#remarks').val('');
            }
        });
        form.on('submit(dy)', function (data) {
            var taskid = $('#task_id').val();
            var ids = $('#ids').val();
            var flowcode = $('#flowcode').val();
            var table = $('#table').val();
            var mode = 'view';
            var url = '/admin/Finishworkitem/jkd?ids=' + ids + '&taskid=' + taskid + '&table=' + table + '&mode=' + mode +'&flowcode='+flowcode;
            var title = "借款单打印";
            top.layui.index.openTabsPage(url, title);  //完成页面跳转
            // $("#dy_html").printArea();
            // return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

    });
</script>
